﻿//////////////////////////////////////////////////
/*
* 任务类  
* 1.如果任务作废 m_bValid 为false
* 2.控制优先级
*	
*/
//////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QMutex>
#include <QAtomicInteger>
#include <QList>
#include <QSharedPointer>

#define NULL_RETURN(x) if(nullptr ==(x)){return;}

class XTask : QObject
{
	Q_OBJECT
public:
	XTask(const QString& left, const QString& right, QObject* parent = nullptr);
	~XTask() {};

	XTask(const XTask*) = delete;
	XTask* operator=(const XTask*) = delete;

public:
	bool Valid() const { return m_bValid; }
	void Valid(bool val) { m_bValid = val; }

	void fastCompareDir(const QString& left, const QString& right);
	void setParam(const QString& left, const QString& right);
	QPair<QString, QString> getParam();

private:
	QMutex m_mutex;
	QAtomicInteger<bool> m_bValid = true;
	QString m_left;
	QString m_right;
	QList<QPair<QString, QString>> m_param;
};

using XTaskPtr = QSharedPointer<XTask>;
using XTaskList = QList<XTaskPtr>;

